<!DOCTYPE html>
<html>
<head>
    {include file="layout:_meta" /}
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">用户分组</label>
        <div class="layui-input-block">
            <div id="xm-select"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
           {:isset($list.phone)?$list.phone:''}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-block">
           {:isset($list.nickname)?$list.nickname:''}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            {if condition="isset($list.state)&&$list.state==1"}
            <input type="checkbox" lay-filter="state"  checked value="1" name="state" lay-skin="switch" lay-text="启用|禁用">
            {else /}
            <input type="checkbox" lay-filter="state"  value="0" name="state" lay-skin="switch" lay-text="启用|禁用">
            {/if}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">注销状态</label>
        <div class="layui-input-block">
            {if condition="isset($list.cancel)&&$list.cancel==1"}
            <input type="checkbox" lay-filter="cancel"  checked value="1" name="cancel" lay-skin="switch" lay-text="正常|注销">
            {else /}
            <input type="checkbox" lay-filter="cancel"  value="0" name="cancel" lay-skin="switch" lay-text="正常|注销">
            {/if}
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
        <input type="hidden" name="token" value="{:isset($list['token'])?$list['token']:''}">
        <input type="button" lay-submit lay-filter="addEdit" id="addEdit" value="确认">
    </div>
</div>
{include file="layout:_footer" /}
<script>
    layui.config({
        base: '__static__/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','xmSelect'], function(){
        var form = layui.form,$ = layui.$,xmSelect = layui.xmSelect;

        //角色多选框
        var xm_select = xmSelect.render({
            el: '#xm-select',
            tips: '请选择分组',
            prop: {name: 'name', value: 'id'},
            name: 'cate_id',
            layVerify: 'required',
            data:[]
        });

        //获取数据以及赋值
        $.get("{:url('user/edit')}",{id:"{:isset($list['id'])?$list['id']:''}"},function (res) {
            xm_select.update({data: res.roleList});
            xm_select.setValue(res.role)
        });

        form.on('switch(state)', function(data){
            this.value = this.checked?1:0;
        });
        form.on('switch(cancel)', function(data){
            this.value = this.checked?1:0;
        });
    })
</script>
</body>
</html>